/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package programaobf;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
 *
 * @author MSK
 */
public class CSVwritera{
    public static String nwl = System.getProperty("line.separator");
    FileInputStream fis = null;
    BufferedInputStream bis = null;
    DataInputStream dis = null;
    FileOutputStream fos = null;
    BufferedOutputStream bos = null;
    DataOutputStream dos = null;
    CSVwritera(File coloap, File pdfrep1) throws FileNotFoundException, IOException{
          if(coloap.exists()){
          fis = new FileInputStream(coloap);
          bis = new BufferedInputStream(fis);
          dis = new DataInputStream(bis);
          fos = new FileOutputStream(pdfrep1);
          bos = new BufferedOutputStream(fos);
          dos = new DataOutputStream(bos);
          dos.writeBytes(";Nai-atraktivni promocii;"+nwl);
          dos.writeBytes("Broj poseshtenia;Promocia;Vunshni stranici"+nwl);
          while (dis.available() != 0 ){
              String barev =  dis.readLine();
              String[] rebac = barev.split(" ");
              dos.writeBytes(rebac[0]+" ; "+rebac[1]+" ; "+ rebac[2]+nwl);
          }
          fos.flush();
          dos.flush();
          fos.close();
          bis.close();
          dos.close();
          fis.close();
          bis.close();
          dis.close();
          System.out.println("The file has been written "+pdfrep1);
          }
          else{
            System.out.println("This file is not exist");}
          }

}
